var dialogId = "";
var sysId = "";
var nodeId = "";
var nodeName = "";
var tableName = "";
var initCode = "";
var dropdownType = "";
var colRuleName = "";
var userName = "";
var deptName = "";
var customPath = "";
var customName = "";
var colGeneMethod = "";
var colType = "";
var colLength = "";
var colDecimal = "";
var initColNameStr = "";
var select1 = "";
var input1 = "";
var select2 = "";
var input2 = "";
var select3 = "";
var colGeneMethodSelect = "";
var configJa = ""; // 组合项配置信息

/*******************************************************************************
 * 页面初始化添加控件
 */
function initForm() {
	var colGeneMethodRule = $("#colGeneMethodRule").val();
	if (colGeneMethodSelect == 1) { // 默认值
		$("#labelDiv").css("display", "block");
		if (dropdownType == 1) { // 参选
			var codeEditor = "<input id='codeName'  class='easyui-combobox' style='width:185px' data-options=";
			codeEditor = codeEditor + '"editable:true,panelHeight:';
			codeEditor = codeEditor
					+ "'auto', valueField:'lookupCode',textField:'lookupName'";
			codeEditor = codeEditor + ',onChange:SelectColChange"';
			codeEditor = codeEditor + "></input>";
			$("#editorDiv").html(codeEditor);
			$.parser.parse('#editorDiv');
			$("#codeName").combobox("loadData", initCode);
			$("#codeName").combobox("setValue", colGeneMethodRule);
		} else if (dropdownType == 2) { // 只选
			var codeEditor = "<input id='codeName' class='easyui-combobox' style='width:185px' data-options=";
			codeEditor = codeEditor + '"editable:false,panelHeight:';
			codeEditor = codeEditor
					+ "'auto', valueField:'lookupCode',textField:'lookupName'";
			codeEditor = codeEditor + ',onSelect:onSelectCol"';
			codeEditor = codeEditor + "></input>";
			$("#editorDiv").html(codeEditor);
			$.parser.parse('#editorDiv');
			$("#codeName").combobox("loadData", initCode);
			$("#codeName").combobox("setValue", colGeneMethodRule);
		} else if (dropdownType == 3) { // 选择
			if (colRuleName == "user") { // 选人
				/*
				 * var userEditor = '<input id="userName" style="width:185px"
				 * data-options="required:true,editable:false" title="选人"
				 * class="easyui-validatebox" readonly="readonly"></input>';
				 * $("#editorDiv").html(userEditor);
				 * $.parser.parse('#editorDiv'); var chargeLeaderCommonSelector =
				 * new CommonSelector("user", "selectDialog",
				 * "colGeneMethodRule", "userName", null, null, null, false,
				 * null, "选人", "600", "350"); chargeLeaderCommonSelector.init();
				 * $("#userName").val(userName);
				 */

				var codeEditor = "<input id='codeName' style='width:185px' class='easyui-combobox' data-options=";
				codeEditor = codeEditor + '"editable:false,panelHeight:';
				codeEditor = codeEditor
						+ "'auto', valueField:'lookupCode',textField:'lookupName'";
				codeEditor = codeEditor + ',onSelect:onSelectCol"';
				codeEditor = codeEditor + "></input>";
				$("#editorDiv").html(codeEditor);
				$.parser.parse('#editorDiv');
				$("#codeName").combobox("loadData", initCode);
				$("#codeName").combobox("setValue", colGeneMethodRule);
			} else if (colRuleName == "dept") { // 选部门
				/*
				 * var userEditor = '<input id="deptName" style="width:185px"
				 * data-options="required:true,editable:false" title="选部门"
				 * class="easyui-validatebox" readonly="readonly"></input>';
				 * $("#editorDiv").html(userEditor);
				 * $.parser.parse('#editorDiv'); var chargeLeaderCommonSelector =
				 * new CommonSelector("dept", "selectDialog",
				 * "colGeneMethodRule", "deptName", null, null, null, false,
				 * null, "选部门", "600", "350");
				 * chargeLeaderCommonSelector.init();
				 * $("#deptName").val(deptName);
				 */
				var codeEditor = "<input id='codeName' style='width:185px' class='easyui-combobox' data-options=";
				codeEditor = codeEditor + '"editable:false,panelHeight:';
				codeEditor = codeEditor
						+ "'auto', valueField:'lookupCode',textField:'lookupName'";
				codeEditor = codeEditor + ',onSelect:onSelectCol"';
				codeEditor = codeEditor + "></input>";
				$("#editorDiv").html(codeEditor);
				$.parser.parse('#editorDiv');
				$("#codeName").combobox("loadData", initCode);
				$("#codeName").combobox("setValue", colGeneMethodRule);
			} else if (colRuleName == "custom") { // 自定义选择页
				// var customPath = result.customPath;
				// var customPath =
				// 'avicit/im/lantop/basic/classtabmanager/ClassTabManager.jsp?tableName=LANTOP_CLASS_TABLE&column=CLASS_CODE&flag=1';
				var customEditor = '<input id="customName" title="自定义选择" style="width:185px" class="easyui-validatebox" readonly="readonly"></input>';
				customEditor = customEditor
						+ '<img src="avicit/platform6/component/css/commonselection/icons_ext/selectorCommon.gif" style="display: block;z-index: 800; position: absolute; float: right; top: 3px; cursor: pointer; right: 18px;" onclick="getKmNoumenon(';
				customEditor = customEditor + "'" + customPath + "'"
						+ ",'分类表信息选择','customName');";
				customEditor = customEditor + '" />';
				$("#editorDiv").html(customEditor);
				$.parser.parse('#editorDiv');
				$("#customName").val(customName);
			}
		} else { // 普通字段
			if (colType == "string" || colType == "clob") { // 字符串
				/*
				 * var stringEditor = '<input id="commonField"
				 * style="width:185px;" onChange="valueChange();" type="text"
				 * class="easyui-validatebox"
				 * data-options="required:true,validType:'; stringEditor =
				 * stringEditor + "'length[0," + colLength + "]'"; stringEditor =
				 * stringEditor + '"></input>';
				 * $("#editorDiv").html(stringEditor);
				 * $.parser.parse('#editorDiv');
				 * $("#commonField").val(colGeneMethodRule);
				 */
				var codeEditor = "<input id='codeName' class='easyui-combobox' style='width:185px' data-options=";
				codeEditor = codeEditor + '"editable:false,panelHeight:';
				codeEditor = codeEditor
						+ "'auto', valueField:'lookupCode',textField:'lookupName'";
				codeEditor = codeEditor + ',onSelect:onStringSelectCol"';
				codeEditor = codeEditor + "></input>";
				codeEditor = codeEditor
						+ '<input id="commonField" style="width:185px;" onChange="valueChange();" type="text" class="easyui-validatebox" data-options="validType:';
				codeEditor = codeEditor + "'length[0," + colLength + "]'";
				codeEditor = codeEditor + '"></input>';
				$("#editorDiv").html(codeEditor);
				$.parser.parse('#editorDiv');
				$("#codeName").combobox("loadData", initCode);
				if (colGeneMethodRule == "currentUser"
						|| colGeneMethodRule == "currentUserName"
						|| colGeneMethodRule == "currentDeptId"
						|| colGeneMethodRule == "currentDeptName"
						|| colGeneMethodRule == "currentOrg"
						|| colGeneMethodRule == "currentQzName"
						|| colGeneMethodRule == "currentQzCode"
						|| colGeneMethodRule == "currentNodeRemark"
						|| colGeneMethodRule == "parentDeptName"
						|| colGeneMethodRule == "parentDeptId"
						|| colGeneMethodRule == "parentDeptCode") {
					$("#codeName").combobox("setValue", colGeneMethodRule);
				} else {
					$('#commonField').val(colGeneMethodRule);
				}
			} else if (colType == "integer") { // 整型
				var integerEditor = '<input id="commonField" style="width:185px;" type="text" class="easyui-numberbox" data-options="onChange:numberChange,required:true,precision:0,validType:';
				integerEditor = integerEditor + "'length[0," + colLength + "]'";
				integerEditor = integerEditor + '"></input>';
				$("#editorDiv").html(integerEditor);
				$.parser.parse('#editorDiv');
				$('#commonField').numberbox('setValue', colGeneMethodRule);
			} else if (colType == "date") { // 日期
				/*
				 * var dateEditor = '<input id="commonField" type="text"
				 * style="width:185px" class="easyui-datebox"
				 * data-options="required:true,editable:false,onSelect:dateSelect" ></input>';
				 * $("#editorDiv").html(dateEditor);
				 * $.parser.parse('#editorDiv');
				 * $('#commonField').datebox('setValue', colGeneMethodRule);
				 */
				var codeEditor = "<input id='codeName' class='easyui-combobox' style='width:185px' data-options=";
				codeEditor = codeEditor + '"editable:false,panelHeight:';
				codeEditor = codeEditor
						+ "'auto', valueField:'lookupCode',textField:'lookupName'";
				codeEditor = codeEditor + ',onSelect:onDateSelectCol"';
				codeEditor = codeEditor + "></input>";
				codeEditor = codeEditor
						+ '<input id="commonField" type="text" style="width:185px" class="easyui-datebox" data-options="editable:false,onSelect:dateSelect" ></input>';
				$("#editorDiv").html(codeEditor);
				$.parser.parse('#editorDiv');
				$("#codeName").combobox("loadData", initCode);
				if (colGeneMethodRule == "currentDate") {
					$("#codeName").combobox("setValue", colGeneMethodRule);
				} else {
					$('#commonField').datebox('setValue', colGeneMethodRule);
				}
			} else if (colType == "float") { // 浮点型
				var floatEditor = '<input id="commonField" style="width:185px;" type="text" class="easyui-numberbox" data-options="onChange:numberChange,required:true,validType:';
				floatEditor = floatEditor + "'length[0," + colLength
						+ "]',precision:" + colDecimal;
				floatEditor = floatEditor + '"></input>';
				$("#editorDiv").html(floatEditor);
				$.parser.parse('#editorDiv');
				$('#commonField').numberbox('setValue', colGeneMethodRule);
			}
			/*
			 * else if (colType == "clob") {// clob var clobEditor = '<input
			 * id="commonField" style="width:185px;" onChange="valueChange();"
			 * type="text" class="easyui-validatebox"
			 * data-options="required:true"></input>';
			 * $("#editorDiv").html(clobEditor); $.parser.parse('#editorDiv');
			 * $("#commonField").val(colGeneMethodRule); }
			 */
		}
	} else if (colGeneMethodSelect == 2) { // 序列
		$("#labelDiv").css("display", "block");
		if (dropdownType == 1) { // 参选
			var selectEditor = '<input id="commonField" style="width:185px;" onChange="valueChange();" type="text" class="easyui-validatebox" data-options="required:true,validType:';
			selectEditor = selectEditor + "'length[0," + colLength + "]'";
			selectEditor = selectEditor + '"></input>';
			$("#editorDiv").html(selectEditor);
			$.parser.parse('#editorDiv');
			$("#commonField").val(colGeneMethodRule);
		} else if (dropdownType == 0) { // 普通字段
			if ("string" == colType) {
				var stringEditor = '<input id="commonField" style="width:185px;" onChange="valueChange();" type="text" class="easyui-validatebox" data-options="required:true,validType:';
				stringEditor = stringEditor + "'length[0," + colLength + "]'";
				stringEditor = stringEditor + '"></input>';
				$("#editorDiv").html(stringEditor);
				$.parser.parse('#editorDiv');
				$("#commonField").val(colGeneMethodRule);
			} else if ("integer" == colType) {
				var integerEditor = '<input id="commonField" style="width:185px;" style="width:185px;" type="text" class="easyui-numberbox" data-options="onChange:numberChange,required:true,precision:0,validType:';
				integerEditor = integerEditor + "'length[0," + colLength + "]'";
				integerEditor = integerEditor + '"></input>';
				$("#editorDiv").html(integerEditor);
				$.parser.parse('#editorDiv');
				$('#commonField').numberbox('setValue', colGeneMethodRule);
			} else if ("float" == colType) {
				var floatEditor = '<input id="commonField" style="width:185px;" type="text" class="easyui-numberbox" data-options="onChange:numberChange,required:true,validType:';
				floatEditor = floatEditor + "'length[0," + colLength
						+ "]',precision:" + colDecimal;
				floatEditor = floatEditor + '"></input>';
				$("#editorDiv").html(floatEditor);
				$.parser.parse('#editorDiv');
				$('#commonField').numberbox('setValue', colGeneMethodRule);
			} else if ("clob" == colType) {
				var clobEditor = '<input id="commonField" style="width:185px;" onChange="valueChange();" type="text" class="easyui-validatebox" data-options="required:true"></input>';
				$("#editorDiv").html(clobEditor);
				$.parser.parse('#editorDiv');
				$("#commonField").val(colGeneMethodRule);
			}
		}
	} else if (colGeneMethodSelect == 4) { // 组合项
		$("#labelDiv").css("display", "block");
		// 根据字段类型初始化控件
		if (colType == "string") {
			var groupEditor = '<a class="easyui-linkbutton" plain="true" iconCls="icon-im-add" onclick="addtr(';
			groupEditor = groupEditor + "'test')";
			groupEditor = groupEditor
					+ '" href="javascript:void(0);" id="addForm"><span style="display: block;float: right;">添加</span></a>';
			groupEditor = groupEditor
					+ '<table border="1px #ooo" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
			groupEditor = groupEditor + '<tr style="border: 0px;">';
			groupEditor = groupEditor + '<td style="border: 0px;">组合字段</td>';
			groupEditor = groupEditor + '<td style="border: 0px;">组合固定值</td>';
			groupEditor = groupEditor + '<td style="border: 0px;"></td>';
			groupEditor = groupEditor + '</tr>';
			groupEditor = groupEditor + '</table>';
			groupEditor = groupEditor
					+ '<table border="1px #ooo" id="test" name="test" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
			if (configJa.length == 0) { // 没有组合项配置时，添加空行
				groupEditor = groupEditor + '<tr id="0" style="border: 0px;">';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="field0" class="easyui-combobox" data-options="valueField: ';
				groupEditor = groupEditor
						+ "'lookupCode',textField: 'lookupName',data:"
						+ initColNameStr + ",editable:false,panelHeight:'100'";
				groupEditor = groupEditor + '"></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="input0" type="text" class="easyui-validatebox"/></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><a class="easyui-linkbutton" plain="true" iconCls="icon-im-remove" onclick="deltr(this);" href="javascript:void(0);" id="deleteForm"><span style="display: block;float: right;">删除</span></a></td>';
				groupEditor = groupEditor + '</tr>';
			}
			// 根据组合项配置信息json循环添加表格行
			for ( var i = 0; i < configJa.length; i++) {
				var tgtColumn = configJa[i].tgtColumn;
				var tgtInput = configJa[i].tgtInput;
				var order = configJa[i].order;
				groupEditor = groupEditor + '<tr id="' + order
						+ '" style="border: 0px;">';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="field'
						+ order
						+ '" class="easyui-combobox" data-options="valueField: ';
				groupEditor = groupEditor
						+ "'lookupCode',textField: 'lookupName',data:"
						+ initColNameStr + ",editable:false,panelHeight:'100'";
				groupEditor = groupEditor + '"></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="input' + order
						+ '" type="text" class="easyui-validatebox" value="'
						+ tgtInput + '"/></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><a class="easyui-linkbutton" plain="true" iconCls="icon-im-remove" onclick="deltr(this);" href="javascript:void(0);" id="deleteForm">删除</a></td>';
				groupEditor = groupEditor + '</tr>';
			}
			groupEditor = groupEditor + '</table>';
			$("#editorDiv").html(groupEditor);
			$.parser.parse('#editorDiv');
			// 下拉列表填值
			for ( var i = 0; i < configJa.length; i++) {
				$("#field" + (i + 1)).combobox('select', configJa[i].tgtColumn);
			}
		} else if (colType == "integer") {
			var groupEditor = '<a class="easyui-linkbutton" plain="true" iconCls="icon-im-add" onclick="addtrInteger(';
			groupEditor = groupEditor + "'test')";
			groupEditor = groupEditor
					+ '" href="javascript:void(0);" id="addForm">添加</a>';
			groupEditor = groupEditor
					+ '<table border="1px #ooo" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
			groupEditor = groupEditor + '<tr style="border: 0px;">';
			groupEditor = groupEditor + '<td style="border: 0px;">组合字段</td>';
			groupEditor = groupEditor + '<td style="border: 0px;">组合固定值</td>';
			groupEditor = groupEditor + '<td style="border: 0px;"></td>';
			groupEditor = groupEditor + '</tr>';
			groupEditor = groupEditor + '</table>';
			groupEditor = groupEditor
					+ '<table border="1px #ooo" id="test" name="test" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
			if (configJa.length == 0) { // 没有组合项配置时，添加空行
				groupEditor = groupEditor + '<tr id="0" style="border: 0px;">';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="field0" class="easyui-combobox" data-options="valueField: ';
				groupEditor = groupEditor
						+ "'lookupCode',textField: 'lookupName',data:"
						+ initColNameStr + ",editable:false,panelHeight:'100'";
				groupEditor = groupEditor + '"></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="input0" type="text" class="easyui-numberbox"/></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><a class="easyui-linkbutton" plain="true" iconCls="icon-im-remove" onclick="deltr(this);" href="javascript:void(0);" id="deleteForm">删除</a></td>';
				groupEditor = groupEditor + '</tr>';
			}
			// 根据组合项配置信息json循环添加表格行
			for ( var i = 0; i < configJa.length; i++) {
				var tgtColumn = configJa[i].tgtColumn;
				var tgtInput = configJa[i].tgtInput;
				var order = configJa[i].order;
				groupEditor = groupEditor + '<tr id="' + order
						+ '" style="border: 0px;">';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="field'
						+ order
						+ '" class="easyui-combobox" data-options="valueField: ';
				groupEditor = groupEditor
						+ "'lookupCode',textField: 'lookupName',data:"
						+ initColNameStr + ",editable:false,panelHeight:'100'";
				groupEditor = groupEditor + '"></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="input' + order
						+ '" type="text" class="easyui-numberbox" value="'
						+ tgtInput + '"/></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><a class="easyui-linkbutton" plain="true" iconCls="icon-im-remove" onclick="deltr(this);" href="javascript:void(0);" id="deleteForm">删除</a></td>';
				groupEditor = groupEditor + '</tr>';
			}
			groupEditor = groupEditor + '</table>';
			$("#editorDiv").html(groupEditor);
			$.parser.parse('#editorDiv');
			// 下拉列表填值
			for ( var i = 0; i < configJa.length; i++) {
				$("#field" + (i + 1)).combobox('select', configJa[i].tgtColumn);
			}
		} else if (colType == "float") {
			var groupEditor = '<a class="easyui-linkbutton" plain="true" iconCls="icon-im-add" onclick="addtrFloat(';
			groupEditor = groupEditor + "'test')";
			groupEditor = groupEditor
					+ '" href="javascript:void(0);" id="addForm">添加</a>';
			groupEditor = groupEditor
					+ '<table border="1px #ooo" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
			groupEditor = groupEditor + '<tr style="border: 0px;">';
			groupEditor = groupEditor + '<td style="border: 0px;">组合字段</td>';
			groupEditor = groupEditor + '<td style="border: 0px;">组合固定值</td>';
			groupEditor = groupEditor + '<td style="border: 0px;"></td>';
			groupEditor = groupEditor + '</tr>';
			groupEditor = groupEditor + '</table>';
			groupEditor = groupEditor
					+ '<table border="1px #ooo" id="test" name="test" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
			if (configJa.length == 0) { // 没有组合项配置时，添加空行
				groupEditor = groupEditor + '<tr id="0" style="border: 0px;">';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="field0" class="easyui-combobox" data-options="valueField: ';
				groupEditor = groupEditor
						+ "'lookupCode',textField: 'lookupName',data:"
						+ initColNameStr + ",editable:false,panelHeight:'100'";
				groupEditor = groupEditor + '"></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="input0" type="text" class="easyui-numberbox"data-options="precision:'
						+ colDecimal + '"/></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><a class="easyui-linkbutton" plain="true" iconCls="icon-im-remove" onclick="deltr(this);" href="javascript:void(0);" id="deleteForm">删除</a></td>';
				groupEditor = groupEditor + '</tr>';
			}
			// 根据组合项配置信息json循环添加表格行
			for ( var i = 0; i < configJa.length; i++) {
				var tgtColumn = configJa[i].tgtColumn;
				var tgtInput = configJa[i].tgtInput;
				var order = configJa[i].order;
				groupEditor = groupEditor + '<tr id="' + order
						+ '" style="border: 0px;">';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="field'
						+ order
						+ '" class="easyui-combobox" data-options="valueField: ';
				groupEditor = groupEditor
						+ "'lookupCode',textField: 'lookupName',data:"
						+ initColNameStr + ",editable:false,panelHeight:'100'";
				groupEditor = groupEditor + '"></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="input' + order
						+ '" type="text" class="easyui-numberbox" value="'
						+ tgtInput + '" data-options="precision:' + colDecimal
						+ '"/></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><a class="easyui-linkbutton" plain="true" iconCls="icon-im-remove" onclick="deltr(this);" href="javascript:void(0);" id="deleteForm">删除</a></td>';
				groupEditor = groupEditor + '</tr>';
			}
			groupEditor = groupEditor + '</table>';
			$("#editorDiv").html(groupEditor);
			$.parser.parse('#editorDiv');
			// 下拉列表填值
			for ( var i = 0; i < configJa.length; i++) {
				$("#field" + (i + 1)).combobox('select', configJa[i].tgtColumn);
			}
		} else if (colType == "clob") {
			var groupEditor = '<a class="easyui-linkbutton" plain="true" iconCls="icon-im-add" onclick="addtr(';
			groupEditor = groupEditor + "'test')";
			groupEditor = groupEditor
					+ '" href="javascript:void(0);" id="addForm">添加</a>';
			groupEditor = groupEditor
					+ '<table border="1px #ooo" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
			groupEditor = groupEditor + '<tr style="border: 0px;">';
			groupEditor = groupEditor + '<td style="border: 0px;">组合字段</td>';
			groupEditor = groupEditor + '<td style="border: 0px;">组合固定值</td>';
			groupEditor = groupEditor + '<td style="border: 0px;"></td>';
			groupEditor = groupEditor + '</tr>';
			groupEditor = groupEditor + '</table>';
			groupEditor = groupEditor
					+ '<table border="1px #ooo" id="test" name="test" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
			if (configJa.length == 0) { // 没有组合项配置时，添加空行
				groupEditor = groupEditor + '<tr id="0" style="border: 0px;">';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="field0" class="easyui-combobox" data-options="valueField: ';
				groupEditor = groupEditor
						+ "'lookupCode',textField: 'lookupName',data:"
						+ initColNameStr + ",editable:false,panelHeight:'100'";
				groupEditor = groupEditor + '"></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="input0" type="text" class="easyui-validatebox"/></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><a class="easyui-linkbutton" plain="true" iconCls="icon-im-remove" onclick="deltr(this);" href="javascript:void(0);" id="deleteForm">删除</a></td>';
				groupEditor = groupEditor + '</tr>';
			}
			// 根据组合项配置信息json循环添加表格行
			for ( var i = 0; i < configJa.length; i++) {
				var tgtColumn = configJa[i].tgtColumn;
				var tgtInput = configJa[i].tgtInput;
				var order = configJa[i].order;
				groupEditor = groupEditor + '<tr id="' + order
						+ '" style="border: 0px;">';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="field'
						+ order
						+ '" class="easyui-combobox" data-options="valueField: ';
				groupEditor = groupEditor
						+ "'lookupCode',textField: 'lookupName',data:"
						+ initColNameStr + ",editable:false,panelHeight:'100'";
				groupEditor = groupEditor + '"></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><input id="input' + order
						+ '" type="text" class="easyui-validatebox" value="'
						+ tgtInput + '"/></td>';
				groupEditor = groupEditor
						+ '<td style="border: 0px;"><a class="easyui-linkbutton" plain="true" iconCls="icon-im-remove" onclick="deltr(this);" href="javascript:void(0);" id="deleteForm">删除</a></td>';
				groupEditor = groupEditor + '</tr>';
			}
			groupEditor = groupEditor + '</table>';
			$("#editorDiv").html(groupEditor);
			$.parser.parse('#editorDiv');
			// 下拉列表填值
			for ( var i = 0; i < configJa.length; i++) {
				$("#field" + (i + 1)).combobox('select', configJa[i].tgtColumn);
			}
		}
	}
}

/*******************************************************************************
 * 生成方式选择事件
 * 
 * @param record
 */
function onSelectGenemethod(record) {
	var id = $('#id').val();
	var colGeneMethod = record.value;
	$('#colGeneMethod').val(colGeneMethod);
	// ajax访问controller判断配置合法性
	$
			.ajax({
				url : 'platform/aos/commtablemanagerController/checkConfig',
				data : {
					id : id,
					colGeneMethod : colGeneMethod,
					tableName : tableName,
					sysId : sysId,
					nodeId : nodeId
				},
				type : 'post',
				dataType : 'json',
				success : function(result) {
					if (result.flag == "failure") {
						$.messager.show({
							title : '提示',
							msg : result.mes,
							timeout : 2000,
							showType : 'slide'
						});
						// 将【生成方式】选择 空，将生成方式规则值清空
						$("#colGeneMethod").combobox("setValue", "0");
						$('#colGeneMethod').val("0");
						$("#colGeneMethodRule").val("");
						$("#labelDiv").css("display", "none");
					} else {
						if (colGeneMethod == 1) { // 默认值
							var codeJson = result.codeJson;
							$("#labelDiv").css("display", "block");
							if (dropdownType == 1) { // 参选
								var codeEditor = "<input id='codeName' style='width:185px' class='easyui-combobox' data-options=";
								codeEditor = codeEditor
										+ '"editable:true,panelHeight:';
								codeEditor = codeEditor
										+ "'auto', valueField:'lookupCode',textField:'lookupName'";
								codeEditor = codeEditor
										+ ',onChange:SelectColChange"';
								codeEditor = codeEditor + "></input>";
								$("#editorDiv").html(codeEditor);
								$.parser.parse('#editorDiv');
								$("#codeName").combobox("loadData", codeJson);
							} else if (dropdownType == 2) { // 只选
								var codeEditor = "<input id='codeName' style='width:185px' class='easyui-combobox' data-options=";
								codeEditor = codeEditor
										+ '"editable:false,panelHeight:';
								codeEditor = codeEditor
										+ "'auto', valueField:'lookupCode',textField:'lookupName'";
								codeEditor = codeEditor
										+ ',onSelect:onSelectCol"';
								codeEditor = codeEditor + "></input>";
								$("#editorDiv").html(codeEditor);
								$.parser.parse('#editorDiv');
								$("#codeName").combobox("loadData", initCode);
							} else if (dropdownType == 3) { // 选择
								if (colRuleName == "user") { // 选人
									/*
									 * // 添加选人控件 var userEditor = '<input
									 * id="userName" style="width:185px;"
									 * data-options="required:true,editable:false"
									 * title="选人" class="easyui-validatebox"
									 * readonly="readonly"></input>';
									 * $("#editorDiv").html(userEditor);
									 * $.parser.parse('#editorDiv'); var
									 * chargeLeaderCommonSelector = new
									 * CommonSelector( "user", "selectDialog",
									 * "colGeneMethodRule", "userName", null,
									 * null, null, false, null, "选人", "600",
									 * "350");
									 * chargeLeaderCommonSelector.init();
									 */
									var codeEditor = "<input id='codeName' style='width:185px' class='easyui-combobox' data-options=";
									codeEditor = codeEditor
											+ '"editable:false,panelHeight:';
									codeEditor = codeEditor
											+ "'auto', valueField:'lookupCode',textField:'lookupName'";
									codeEditor = codeEditor
											+ ',onSelect:onSelectCol"';
									codeEditor = codeEditor + "></input>";
									$("#editorDiv").html(codeEditor);
									$.parser.parse('#editorDiv');
									$("#codeName").combobox("loadData",
											codeJson);
								} else if (colRuleName == "dept") { // 选部门
									/*
									 * var userEditor = '<input id="deptName"
									 * style="width:185px;"
									 * data-options="required:true,editable:false"
									 * title="选部门" class="easyui-validatebox"
									 * readonly="readonly"></input>';
									 * $("#editorDiv").html(userEditor);
									 * $.parser.parse('#editorDiv'); var
									 * chargeLeaderCommonSelector = new
									 * CommonSelector( "dept", "selectDialog",
									 * "colGeneMethodRule", "deptName", null,
									 * null, null, false, null, "选部门", "600",
									 * "350");
									 * chargeLeaderCommonSelector.init();
									 */
									var codeEditor = "<input id='codeName' style='width:185px' class='easyui-combobox' data-options=";
									codeEditor = codeEditor
											+ '"editable:false,panelHeight:';
									codeEditor = codeEditor
											+ "'auto', valueField:'lookupCode',textField:'lookupName'";
									codeEditor = codeEditor
											+ ',onSelect:onSelectCol"';
									codeEditor = codeEditor + "></input>";
									$("#editorDiv").html(codeEditor);
									$.parser.parse('#editorDiv');
									$("#codeName").combobox("loadData",
											codeJson);
								} else if (colRuleName == "custom") { // 自定义选择页
									var customPath = result.customPath;
									// var customPath =
									// 'avicit/im/lantop/basic/classtabmanager/ClassTabManager.jsp?tableName=LANTOP_CLASS_TABLE&column=CLASS_CODE&flag=1';
									var customEditor = '<input id="customName" title="自定义选择" style="width:185px" class="easyui-validatebox" readonly="readonly"></input>';
									customEditor = customEditor
											+ '<img src="avicit/platform6/component/css/commonselection/icons_ext/selectorCommon.gif" style="display: block;z-index: 800; position: absolute; float: right; top: 3px; cursor: pointer; right: 18px;" onclick="getKmNoumenon(';
									customEditor = customEditor + "'"
											+ customPath + "'"
											+ ",'分类表信息选择','customName');";
									customEditor = customEditor + '" />';
									$("#editorDiv").html(customEditor);
									$.parser.parse('#editorDiv');
								}
							} else { // 普通字段
								if (colType == "string" || colType == "clob") { // 字符串
									/*
									 * var stringEditor = '<input
									 * id="commonField" style="width:185px;"
									 * onChange="valueChange();" type="text"
									 * class="easyui-validatebox"
									 * data-options="required:true,validType:';
									 * stringEditor = stringEditor +
									 * "'length[0," + colLength + "]'";
									 * stringEditor = stringEditor + '"></input>';
									 * $("#editorDiv").html(stringEditor);
									 * $.parser.parse('#editorDiv');
									 */
									var codeEditor = "<input id='codeName' style='width:185px' class='easyui-combobox' data-options=";
									codeEditor = codeEditor
											+ '"editable:false,panelHeight:';
									codeEditor = codeEditor
											+ "'auto', valueField:'lookupCode',textField:'lookupName'";
									codeEditor = codeEditor
											+ ',onSelect:onStringSelectCol"';
									codeEditor = codeEditor + "></input>";
									codeEditor = codeEditor
											+ '<input id="commonField" style="width:185px;" onChange="valueChange();" type="text" class="easyui-validatebox" data-options="validType:';
									codeEditor = codeEditor + "'length[0,"
											+ colLength + "]'";
									codeEditor = codeEditor + '"></input>';
									$("#editorDiv").html(codeEditor);
									$.parser.parse('#editorDiv');
									$("#codeName").combobox("loadData",
											codeJson);
								} else if (colType == "integer") { // 整型
									var integerEditor = '<input id="commonField" style="width:185px;" type="text" class="easyui-numberbox" data-options="onChange:numberChange,required:true,precision:0,validType:';
									integerEditor = integerEditor
											+ "'length[0," + colLength + "]'";
									integerEditor = integerEditor
											+ '"></input>';
									$("#editorDiv").html(integerEditor);
									$.parser.parse('#editorDiv');
								} else if (colType == "date") { // 日期
									/*
									 * var dateEditor = '<input
									 * id="commonField" style="width:185px;"
									 * type="text" class="easyui-datebox"
									 * data-options="required:true,editable:false,onSelect:dateSelect" ></input>';
									 * $("#editorDiv").html(dateEditor);
									 * $.parser.parse('#editorDiv');
									 */
									var codeEditor = "<input id='codeName' style='width:185px' class='easyui-combobox' data-options=";
									codeEditor = codeEditor
											+ '"editable:false,panelHeight:';
									codeEditor = codeEditor
											+ "'auto', valueField:'lookupCode',textField:'lookupName'";
									codeEditor = codeEditor
											+ ',onSelect:onDateSelectCol"';
									codeEditor = codeEditor + "></input>";
									codeEditor = codeEditor
											+ '<input id="commonField" type="text" style="width:185px" class="easyui-datebox" data-options="editable:false,onSelect:dateSelect" ></input>';
									$("#editorDiv").html(codeEditor);
									$.parser.parse('#editorDiv');
									$("#codeName").combobox("loadData",
											codeJson);
								} else if (colType == "float") { // 浮点型
									var floatEditor = '<input id="commonField" style="width:185px;" type="text" class="easyui-numberbox" data-options="onChange:numberChange,required:true,validType:';
									floatEditor = floatEditor + "'length[0,"
											+ colLength + "]',precision:"
											+ colDecimal;
									floatEditor = floatEditor + '"></input>';
									$("#editorDiv").html(floatEditor);
									$.parser.parse('#editorDiv');
								}
							}
						} else if (colGeneMethod == 2) { // 序列
							$("#labelDiv").css("display", "block");
							if (dropdownType == 1) { // 参选
								var selectEditor = '<input id="commonField" style="width:185px;" onChange="valueChange();" type="text" class="easyui-validatebox" data-options="required:true,validType:';
								selectEditor = selectEditor + "'length[0,"
										+ colLength + "]'";
								selectEditor = selectEditor + '"></input>';
								$("#editorDiv").html(selectEditor);
								$.parser.parse('#editorDiv');
							} else if (dropdownType == 0) { // 普通字段
								// string,integer,float,colb可以;分别添加对应的输入框
								if ("string" == colType) {
									var stringEditor = '<input id="commonField" style="width:185px;" onChange="valueChange();" type="text" class="easyui-validatebox" data-options="required:true,validType:';
									stringEditor = stringEditor + "'length[0,"
											+ colLength + "]'";
									stringEditor = stringEditor + '"></input>';
									$("#editorDiv").html(stringEditor);
									$.parser.parse('#editorDiv');
								} else if ("integer" == colType) {
									var integerEditor = '<input id="commonField" style="width:185px;" type="text" class="easyui-numberbox" data-options="onChange:numberChange,required:true,precision:0,validType:';
									integerEditor = integerEditor
											+ "'length[0," + colLength + "]'";
									integerEditor = integerEditor
											+ '"></input>';
									$("#editorDiv").html(integerEditor);
									$.parser.parse('#editorDiv');
								} else if ("float" == colType) {
									var floatEditor = '<input id="commonField" style="width:185px;" type="text" class="easyui-numberbox" data-options="onChange:numberChange,required:true,validType:';
									floatEditor = floatEditor + "'length[0,"
											+ colLength + "]',precision:"
											+ colDecimal;
									floatEditor = floatEditor + '"></input>';
									$("#editorDiv").html(floatEditor);
									$.parser.parse('#editorDiv');
								} else if ("clob" == colType) {
									var clobEditor = '<input id="commonField" style="width:185px;" onChange="valueChange();" type="text" class="easyui-validatebox" data-options="required:true"></input>';
									$("#editorDiv").html(clobEditor);
									$.parser.parse('#editorDiv');
								}
							}
						} else if (colGeneMethod == 3) { // 顺带
							// 将colGeneMethodRule值清空
							$("#colGeneMethodRule").val("");
							// 隐藏标题，输入框
							$("#labelDiv").css("display", "none");
						} else if (colGeneMethod == 4) { // 组合项
							$("#labelDiv").css("display", "block");
							// 将隐藏域中的值清空
							$("#colGeneMethodRule").val("");
							var colNameStr = result.colNameStr;
							// 添加控件,根据字段类型添加不同输入框
							if (colType == "string") {
								var groupEditor = '<a class="easyui-linkbutton" plain="true" iconCls="icon-im-add" onclick="addtr(';
								groupEditor = groupEditor + "'test')";
								groupEditor = groupEditor
										+ '" href="javascript:void(0);" id="addForm"><span style="display: block;float: right;">添加</span></a>';
								groupEditor = groupEditor
										+ '<table border="1px #ooo" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
								groupEditor = groupEditor
										+ '<tr style="border: 0px;">';
								groupEditor = groupEditor
										+ '<td style="border: 0px;">组合字段</td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;">组合固定值</td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"></td>';
								groupEditor = groupEditor + '</tr>';
								groupEditor = groupEditor + '</table>';
								groupEditor = groupEditor
										+ '<table border="1px #ooo" id="test" name="test" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
								groupEditor = groupEditor
										+ '<tr id="1" style="border: 0px;">';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"><input id="field1" class="easyui-combobox" data-options="valueField: ';
								groupEditor = groupEditor
										+ "'lookupCode',textField: 'lookupName',data:"
										+ colNameStr
										+ ",editable:false,panelHeight:'100'";
								groupEditor = groupEditor + '"></td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"><input id="input1" type="text" class="easyui-validatebox"/></td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"><a class="easyui-linkbutton" plain="true" iconCls="icon-im-remove" onclick="deltr(this);" href="javascript:void(0);" id="deleteForm"><span style="display: block;float: right;">删除</span></a></td>';
								groupEditor = groupEditor + '</tr>';
								groupEditor = groupEditor + '</table>';
								$("#editorDiv").html(groupEditor);
								$.parser.parse('#editorDiv');
							} else if (colType == "integer") {
								var groupEditor = '<a class="easyui-linkbutton" plain="true" iconCls="icon-im-add" onclick="addtrInteger(';
								groupEditor = groupEditor + "'test')";
								groupEditor = groupEditor
										+ '" href="javascript:void(0);" id="addForm">添加</a>';
								groupEditor = groupEditor
										+ '<table border="1px #ooo" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
								groupEditor = groupEditor
										+ '<tr style="border: 0px;">';
								groupEditor = groupEditor
										+ '<td style="border: 0px;">组合字段</td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;">组合固定值</td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"></td>';
								groupEditor = groupEditor + '</tr>';
								groupEditor = groupEditor + '</table>';
								groupEditor = groupEditor
										+ '<table border="1px #ooo" id="test" name="test" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
								groupEditor = groupEditor
										+ '<tr id="1" style="border: 0px;">';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"><input id="field1" class="easyui-combobox" data-options="valueField: ';
								groupEditor = groupEditor
										+ "'lookupCode',textField: 'lookupName',data:"
										+ colNameStr
										+ ",editable:false,panelHeight:'100'";
								groupEditor = groupEditor + '"></td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"><input id="input1" type="text" class="easyui-numberbox"/></td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"><a class="easyui-linkbutton" plain="true" iconCls="icon-im-remove" onclick="deltr(this);" href="javascript:void(0);" id="deleteForm">删除</a></td>';
								groupEditor = groupEditor + '</tr>';
								groupEditor = groupEditor + '</table>';
								$("#editorDiv").html(groupEditor);
								$.parser.parse('#editorDiv');
							} else if (colType == "float") {
								var groupEditor = '<a class="easyui-linkbutton" plain="true" iconCls="icon-im-add" onclick="addtrFloat(';
								groupEditor = groupEditor + "'test')";
								groupEditor = groupEditor
										+ '" href="javascript:void(0);" id="addForm">添加</a>';
								groupEditor = groupEditor
										+ '<table border="1px #ooo" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
								groupEditor = groupEditor
										+ '<tr style="border: 0px;">';
								groupEditor = groupEditor
										+ '<td style="border: 0px;">组合字段</td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;">组合固定值</td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"></td>';
								groupEditor = groupEditor + '</tr>';
								groupEditor = groupEditor + '</table>';
								groupEditor = groupEditor
										+ '<table border="1px #ooo" id="test" name="test" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
								groupEditor = groupEditor
										+ '<tr id="1" style="border: 0px;">';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"><input id="field1" class="easyui-combobox" data-options="valueField: ';
								groupEditor = groupEditor
										+ "'lookupCode',textField: 'lookupName',data:"
										+ colNameStr
										+ ",editable:false,panelHeight:'100'";
								groupEditor = groupEditor + '"></td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"><input id="input1" type="text" class="easyui-numberbox" data-options="precision:'
										+ colDecimal + '"/></td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"><a class="easyui-linkbutton" plain="true" iconCls="icon-im-remove" onclick="deltr(this);" href="javascript:void(0);" id="deleteForm">删除</a></td>';
								groupEditor = groupEditor + '</tr>';
								groupEditor = groupEditor + '</table>';
								$("#editorDiv").html(groupEditor);
								$.parser.parse('#editorDiv');
							} else if (colType == "clob") {
								var groupEditor = '<a class="easyui-linkbutton" plain="true" iconCls="icon-im-add" onclick="addtr(';
								groupEditor = groupEditor + "'test')";
								groupEditor = groupEditor
										+ '" href="javascript:void(0);" id="addForm">添加</a>';
								groupEditor = groupEditor
										+ '<table border="1px #ooo" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
								groupEditor = groupEditor
										+ '<tr style="border: 0px;">';
								groupEditor = groupEditor
										+ '<td style="border: 0px;">组合字段</td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;">组合固定值</td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"></td>';
								groupEditor = groupEditor + '</tr>';
								groupEditor = groupEditor + '</table>';
								groupEditor = groupEditor
										+ '<table border="1px #ooo" id="test" name="test" class="test" cellpadding="0" cellspacing="0" width="100%" style="border: 0px;">';
								groupEditor = groupEditor
										+ '<tr id="1" style="border: 0px;">';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"><input id="field1" class="easyui-combobox" data-options="valueField: ';
								groupEditor = groupEditor
										+ "'lookupCode',textField: 'lookupName',data:"
										+ colNameStr
										+ ",editable:false,panelHeight:'100'";
								groupEditor = groupEditor + '"></td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"><input id="input1" type="text" class="easyui-validatebox"/></td>';
								groupEditor = groupEditor
										+ '<td style="border: 0px;"><a class="easyui-linkbutton" plain="true" iconCls="icon-im-remove" onclick="deltr(this);" href="javascript:void(0);" id="deleteForm">删除</a></td>';
								groupEditor = groupEditor + '</tr>';
								groupEditor = groupEditor + '</table>';
								$("#editorDiv").html(groupEditor);
								$.parser.parse('#editorDiv');
							}
						} else if (colGeneMethod == 0) {
							// 去掉标签，值置空
							$("#labelDiv").css("display", "none");
							$("#colGeneMethod").val("");
							$("#colGeneMethodRule").val("");
						}
					}
				}
			});
}

/*******************************************************************************
 * 通用代码下拉列表点击后将lookupCode赋给隐藏域
 * 
 * @param record
 */
function onSelectCol(record) {
	$("#colGeneMethodRule").val(record.lookupCode);
}

/*******************************************************************************
 * 时间日期型输入或选择值后将lookupCode赋给隐藏域
 * 
 * @param record
 */
function onDateSelectCol(record) {
	$("#colGeneMethodRule").val(record.lookupCode);
	$('#commonField').datebox('setValue', '');
}

/*******************************************************************************
 * 字符串型输入或选择值后将lookupCode赋给隐藏域
 * 
 * @param record
 */
function onStringSelectCol(record) {
	$("#colGeneMethodRule").val(record.lookupCode);
	$('#commonField').val('');
}

/*******************************************************************************
 * 
 * 保存
 */
function saveForm() {
	var id = $('#id').val();
	var colGeneMethod = $('#colGeneMethod').val();
	var colGeneMethodRule = $('#colGeneMethodRule').val();
	// 空不能有值
	if (colGeneMethod == "0") {
		if (!colGeneMethodRule == "") {
			$.messager.show({
				title : '提示',
				msg : '【空】的生成方式规则必须为空',
				timeout : 2000,
				showType : 'slide'
			});
			return false;
		}
	}
	// 默认值必须有值
	if (colGeneMethod == "1") {
		if (colGeneMethodRule == "") {
			$.messager.show({
				title : '提示',
				msg : '请选择默认值',
				timeout : 2000,
				showType : 'slide'
			});
			return false;
		}
	}
	// 序列必须有值
	if (colGeneMethod == "2") {
		if (colGeneMethodRule == "") {
			$.messager.show({
				title : '提示',
				msg : '请输入生成方式规则',
				timeout : 2000,
				showType : 'slide'
			});
			return false;
		}
	}
	// 顺带不能有值
	if (colGeneMethod == "3") {
		if (!colGeneMethodRule == "") {
			$.messager.show({
				title : '提示',
				msg : '【顺带】的生成方式规则必须为空',
				timeout : 2000,
				showType : 'slide'
			});
			return false;
		}
	}
	// 验证普通字段长度
	var validateFlag = $('#formConfig').form('validate');
	if (validateFlag == false) {
		return false;
	}
	// 组合项配置信息
	var tb = $("#test");
	var tl = tb.find("tr").length;
	var json = "[";
	for ( var i = 0; i < tl; i++) {
		json = json + "{";
		for ( var j = 0; j < 2; j++) {
			if (j == 0) {
				var a;
				a = $("#test tr:eq(" + i + ") td:eq(" + j + ")").find('input')
						.combobox('getValue');
				json = json + j + ":'" + a + "',";
			}
			if (j == 1) {
				var a;
				a = $("#test tr:eq(" + i + ") td:eq(" + j + ")").find('input')
						.val();
				json = json + j + ":'" + a + "'";
			}
		}
		json = json + "},";
	}
	json = json.substring(0, json.length - 1);
	json = json + "]";
	// 组合项必须有值
	if (colGeneMethod == "4") {
		// 循环组合项配置表格，判断是否有值
		var flag = true;
		for ( var i = 0; i < tl; i++) {
			var testJson = "{";
			for ( var j = 0; j < 2; j++) {
				if (j == 0) {
					var a;
					a = $("#test tr:eq(" + i + ") td:eq(" + j + ")").find(
							'input').combobox('getValue');
					testJson = testJson + j + ":'" + a + "',";
				}
				if (j == 1) {
					var a;
					a = $("#test tr:eq(" + i + ") td:eq(" + j + ")").find(
							'input').val();
					testJson = testJson + j + ":'" + a + "'";
				}
			}
			testJson = testJson + "}";
			if (testJson == "{0:'',1:''}") {
				flag = false;
				break;
			} else {
				flag = true;
			}
		}
		if (!flag) {
			$.messager.show({
				title : '提示',
				msg : '请选择组合字段或输入组合固定值！',
				timeout : 2000,
				showType : 'slide'
			});
			return false;
		}
	}
	// 将设置参数传回父页面统一保存
	parent.idSet = id;
	parent.colGeneMethodSet = colGeneMethod;
	parent.colGeneMethodRuleSet = colGeneMethodRule;
	parent.groupJson = json;
	// 执行父页面保存方法
	parent.accept();
	// 关闭子页面
	if (parent != null && parent.$('#' + dialogId) != null) {
		parent.$('#' + dialogId).dialog('close');
	}
}

/*******************************************************************************
 * 重置
 */
function resetForm(formName) {
	// $('#' + formName).form('reset');
	initForm();
}

/*******************************************************************************
 * 返回
 */
function closeWindow() {
	if (parent != null && parent.$('#' + dialogId) != null) {
		// 父页面数据还原
		var parentDatagrid = parent.$("#cbbTabColumnsDataGrid");
		var row = parentDatagrid.datagrid('getSelected');
		var index = parentDatagrid.datagrid('getRowIndex', row);
		parentDatagrid.datagrid('endEdit', index);
		parentDatagrid.datagrid('addEditor', { // 添加【生成方式规则显示】编辑器
			field : 'colValueName',
			editor : {
				type : 'text'
			}
		});
		parentDatagrid.datagrid('beginEdit', index);
		// 获取生成方式对应editor
		var editors = parentDatagrid.datagrid('getEditors', index);
		editors[5].target.combobox('setValue', parent.colGeneMethodOld); // 生成方式
		editors[6].target.val(parent.colGeneMethodRuleOld); // 生成方式隐藏值
		editors[7].target.val(parent.colValueNameOld); // 生成方式显示值
		editors[7].target.prop('readonly', true); // 设置只读
		parentDatagrid.datagrid('endEdit', index);
		parent.$('#' + dialogId).dialog('close');
	}
}
/**
 * 自定义弹出框
 */
function getKmNoumenon(path, colTitle, colName) {
	var dialogId = "customDialog";
	var toActionUrl = "platform/cbb/billDefineManagerController/toCustomSelect?dialogId="
			+ dialogId + "&path=" + path + "&colName=" + colName;
	var ruDialog = new CommonDialog(dialogId, "500", "410", toActionUrl,
			colTitle, false, true, false);
	ruDialog.show();
}

/**
 * 自定义页面回填值
 * 
 * @param ids
 */
function customValues(customIds, customNames, colName) {
	$('#colGeneMethodRule').val(customIds);
	$('#customName').val(customNames);
}

/*******************************************************************************
 * 普通字段改变值时给隐藏域赋值
 */
function valueChange(id) {
	$("#colGeneMethodRule").val($("#commonField").val());
	$("#codeName").combobox('select', '');
}

/*******************************************************************************
 * 日期类字段隐藏域填值
 * 
 * @param date
 */
function dateSelect(date) {
	var y = date.getFullYear();
	var m = date.getMonth() + 1;
	var d = date.getDate();
	var dateStr = y + '-' + m + '-' + d;
	$("#colGeneMethodRule").val(dateStr);
	$("#codeName").combobox('select', '');
}
/*******************************************************************************
 * 整型、浮点型字段给隐藏域填值
 * 
 * @param newValue
 * @param oldValue
 */
function numberChange(newValue, oldValue) {
	$("#colGeneMethodRule").val(newValue);
}

/*******************************************************************************
 * 参选给隐藏域赋值
 * 
 * @param newValue
 * @param oldValue
 */
function SelectColChange(newValue, oldValue) {
	$("#colGeneMethodRule").val(newValue);
}

/*******************************************************************************
 * 添加一行,字符串型字段
 * 
 * @param id
 * @returns {Boolean}
 */
function addtr(id) {
	var tr_id = $("#test>tbody>tr:last").attr("id");
	var field = $("#field" + tr_id).combobox('getValue');
	var input = $("#input" + tr_id).val();
	if (field == '' && input == '') {
		$.messager.show({
			title : '提示',
			msg : '请选择组合字段或填写组合固定值！',
			timeout : 2000,
			showType : 'slide'
		});
		return false;
	} else {
		tr_id++;
		var select = 'data-options="editable:false, valueField:'
				+ "'lookupCode',textField:'lookupName',panelHeight:'100',data: "
				+ initColNameStr + '"';
		str = "<tr id = '"
				+ tr_id
				+ "' style='border: 0px;'>"
				+ "<td style='border: 0px;'><input "
				+ 'id="field'
				+ tr_id
				+ '"'
				+ "class='easyui-combobox' "
				+ select
				+ "></td>"
				+ "<td style='border: 0px;'><input "
				+ 'id="input'
				+ tr_id
				+ '"'
				+ " type='text' class='easyui-validatebox'/></td>"
				+ "<td style='border: 0px;'><a class='easyui-linkbutton' plain='true' iconCls='icon-im-remove' onclick='deltr(this);'href='javascript:void(0);' id='deleteForm'><span style='display: block;float: right;'>删除</span></a></td>"
				+ "</tr>";
		$('#' + id).append(str);
		$.parser.parse('#' + tr_id);
	}
}

/*******************************************************************************
 * 添加一行,整型字段
 * 
 * @param id
 * @returns {Boolean}
 */
function addtrInteger(id) {
	var tr_id = $("#test>tbody>tr:last").attr("id");
	var field = $("#field" + tr_id).combobox('getValue');
	var input = $("#input" + tr_id).numberbox('getValue');
	if (field == '' && input == '') {
		$.messager.show({
			title : '提示',
			msg : '请选择组合字段或填写组合固定值！',
			timeout : 2000,
			showType : 'slide'
		});
		return false;
	} else {
		tr_id++;
		var select = 'data-options="editable:false, valueField:'
				+ "'lookupCode',textField:'lookupName',panelHeight:'100',data: "
				+ initColNameStr + '"';
		str = "<tr id = '"
				+ tr_id
				+ "' style='border: 0px;'>"
				+ "<td style='border: 0px;'><input "
				+ 'id="field'
				+ tr_id
				+ '"'
				+ "class='easyui-combobox' "
				+ select
				+ "></td>"
				+ "<td style='border: 0px;'><input "
				+ 'id="input'
				+ tr_id
				+ '"'
				+ " type='text' class='easyui-numberbox'/></td>"
				+ "<td style='border: 0px;'><a class='easyui-linkbutton' plain='true' iconCls='icon-im-remove' onclick='deltr(this);'href='javascript:void(0);' id='deleteForm'><span style='display: block;float: right;'>删除</span></a></td>"
				+ "</tr>";
		$('#' + id).append(str);
		$.parser.parse('#' + tr_id);
	}
}

/*******************************************************************************
 * 添加一行,浮点型字段
 * 
 * @param id
 * @returns {Boolean}
 */
function addtrFloat(id) {
	var tr_id = $("#test>tbody>tr:last").attr("id");
	var field = $("#field" + tr_id).combobox('getValue');
	var input = $("#input" + tr_id).numberbox('getValue');
	if (field == '' && input == '') {
		$.messager.show({
			title : '提示',
			msg : '请选择组合字段或填写组合固定值！',
			timeout : 2000,
			showType : 'slide'
		});
		return false;
	} else {
		tr_id++;
		var select = 'data-options="editable:false, valueField:'
				+ "'lookupCode',textField:'lookupName',panelHeight:'100',data: "
				+ initColNameStr + '"';
		str = "<tr id = '"
				+ tr_id
				+ "' style='border: 0px;'>"
				+ "<td style='border: 0px;'><input "
				+ 'id="field'
				+ tr_id
				+ '"'
				+ "class='easyui-combobox' "
				+ select
				+ "></td>"
				+ "<td style='border: 0px;'><input "
				+ 'id="input'
				+ tr_id
				+ '"'
				+ " type='text' class='easyui-numberbox' data-options='precision:"
				+ colDecimal
				+ "'/></td>"
				+ "<td style='border: 0px;'><a class='easyui-linkbutton' plain='true' iconCls='icon-im-remove' onclick='deltr(this);'href='javascript:void(0);' id='deleteForm'><span style='display: block;float: right;'>删除</span></a></td>"
				+ "</tr>";
		$('#' + id).append(str);
		$.parser.parse('#' + tr_id);
	}
}

/*******************************************************************************
 * 删除一行
 * 
 * @param clickTd
 */
function deltr(clickTd) {
	var tb = $("#test");
	var tl = tb.find("tr").length;
	if (tl == 1) { // 只剩下一行时不允许删除
		$.messager.show({
			title : '提示',
			msg : '不能删除最后一行！',
			timeout : 2000,
			showType : 'slide'
		});
		return false;
	}
	var tr = $(clickTd).parent().parent();
	tr.remove();
}
window.onresize = comboboxHidePanel;